/*
    模型管理相关的API请求函数
*/
import request from '@/utils/request'

const api_base = 'http://localhost:5000'

export default {
  // 获取模型列表（带分页）
  fetchModels(params) {
    return request({
      url: `${api_base}/models/info`,
      method: 'get',
      params: {
        page: params.page || 1,
        limit: params.limit || 10,
        name: params.name || '',
        status: params.status || ''
      }
    })
  },

  // 创建模型
  createModel(formData) {
    return request({
      url: `${api_base}/models/create`,
      method: 'post',
      data: formData
    })
  },

  // 更新数据集元信息
  updateDataset(id, data) {
    return request({
      url: `${api_base}/datasets/${id}`,
      method: 'put',
      data: data
    })
  },

  // 删除数据集
  deleteDataset(id) {
    return request({
      url: `${api_base}/datasets/${id}`,
      method: 'delete'
    })
  },

  // 验证数据集
  verifyDataset(id) {
    return request({
      url: `${api_base}/datasets/${id}/verify`,
      method: 'post'
    })
  },

  // 下载数据集
  downloadDataset(id) {
    return request({
      url: `${api_base}/datasets/${id}/download`,
      method: 'get',
      responseType: 'blob'
    })
  }
}